<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增工单管理')"/>
</head>
<body>
<form class="layui-form">
    <div class="mainBox">
        <div class="main-container">
                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">标题：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="title" placeholder="请输入标题"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">620 数量：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="lowNum" placeholder="请输入620 数量"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">650 数量：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="highNum" placeholder="请输入650 数量"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">其他 数量：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="otherNum" placeholder="请输入其他 数量"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">配送人：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="sender" placeholder="请输入配送人"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">出库人：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="invOutBy" placeholder="请输入出库人"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">接收者：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="accepter" placeholder="请输入接收者"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">出库时间：</label>
                                <div class="layui-input-block">
                                    <div class="input-group date">
                                        <input type="text" name="invOutTime" class="layui-input"
                                               id="invOutTime" >
                                    </div>
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">配送时间：</label>
                                <div class="layui-input-block">
                                    <div class="input-group date">
                                        <input type="text" name="sendTime" class="layui-input"
                                               id="sendTime" >
                                    </div>
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">接收时间：</label>
                                <div class="layui-input-block">
                                    <div class="input-group date">
                                        <input type="text" name="acceptTime" class="layui-input"
                                               id="acceptTime" >
                                    </div>
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">工单状态：</label>
                                <div class="layui-input-block">
                                                                            <div class="radio-box" radio-dict-code="input" name="status">
                                        </div>
                                                                    </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">抄送列表id：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="carbonCopyList" placeholder="请输入抄送列表id"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">取货单位id：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="invOutDept" placeholder="请输入取货单位id"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">收货单位id 去向部门id：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="acceptDept" placeholder="请输入收货单位id 去向部门id"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">内容：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="content" placeholder="请输入内容"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">修改人：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="updateName" placeholder="请输入修改人"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">工单发起人名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="createName" placeholder="请输入工单发起人名称"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">配送人名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="senderName" placeholder="请输入配送人名称"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">出库人名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="invOutName" placeholder="请输入出库人名称"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">接收人名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="accepterName" placeholder="请输入接收人名称"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">取货部门名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="invOutDeptName" placeholder="请输入取货部门名称"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">收货部门名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="acceptDeptName" placeholder="请输入收货部门名称"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                                                                                                                                                <div class="layui-form-item">
                                <label class="layui-form-label">是否逻辑删除：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="enable" placeholder="请输入是否逻辑删除"
                                           class="layui-input" />
                                </div>
                            </div>
                                                                                </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="order-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
</body>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">

    layui.use(['form', 'jquery', 'laydate', 'dictionary'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;

        let prefix = "/work/order/"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                laydate.render({
                            elem: '#invOutTime'
                        });
                                                                                                                                                                        laydate.render({
                            elem: '#sendTime'
                        });
                                                                                                                                                                        laydate.render({
                            elem: '#acceptTime'
                        });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
        form.on('submit(order-save)', function (data) {
            for (var key in data.field) {
                var type = $(data.form).find("input[name='" + key + "']").attr("type");
                if (type == "checkbox") {
                    var value = "";
                    $(data.form).find("input[name='" + key + "']:checked").each(function () {
                        value += $(this).val() + ",";
                    })
                    if (value != "") {
                        value = value.substr(0, value.length - 1);
                        data.field[key] = value;
                    }

                }
            }
            $.ajax({
                url: prefix + 'save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                            parent.layui.table.reload("order-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    });
</script>
</html>